//
//  ChooseGetServerTypeTableViewCell.m
//  PYWGetColor
//
//  Created by 杜文杰 on 2018/6/14.
//  Copyright © 2018年 dwj. All rights reserved.
//

#import "ChooseGetServerTypeTableViewCell.h"
@interface ChooseGetServerTypeTableViewCell()
@property (nonatomic, strong) UIImageView *headerImageView; // 图片是否选中
@property (nonatomic, strong) UILabel *titleLabel; // 标题
@property (nonatomic, strong) UILabel *detailLabel; // 副标题
@end

@implementation ChooseGetServerTypeTableViewCell
- (void)setDataDic:(NSDictionary *)dataDic
{
    self.titleLabel.text = dataDic[@"titleName"];
    self.detailLabel.text = dataDic[@"detailName"];
    if ([dataDic[@"imgSelected"] isEqualToString:@"1"]) {
        self.headerImageView.image = [UIImage imageNamed:@"btn_choose.2"];
    }else{
        self.headerImageView.image = [UIImage imageNamed:@"btn_choose.1"];
    }
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.separatorInset = UIEdgeInsetsZero;
        
        [self.contentView addSubview:self.headerImageView];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.detailLabel];
        
        __weak typeof(self)weakself = self;
        [self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(weakself.mas_centerY);
            make.width.height.mas_offset(20 / WIDTH_6S_SCALE);
            make.right.equalTo(weakself.mas_right).offset(-20 / WIDTH_6S_SCALE);
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakself.mas_top).offset((75 / HEIGHT_6S_SCALE - 40 / HEIGHT_6S_SCALE) *0.5);
            make.left.equalTo(weakself.mas_left).offset(10 / WIDTH_6S_SCALE);
            make.height.mas_offset(20 / HEIGHT_6S_SCALE);
        }];
        [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakself.mas_left).offset(10 / WIDTH_6S_SCALE);
            make.top.equalTo(weakself.titleLabel.mas_bottom);
            make.height.mas_offset(20 / HEIGHT_6S_SCALE);
        }];
        UIView *lineView = [[UIView alloc]init];
        lineView.backgroundColor = getColor(dividerColor);
        [self.contentView addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakself.titleLabel.mas_left);
            make.right.equalTo(weakself);
            make.bottom.equalTo(weakself.mas_bottom).offset(-1 / HEIGHT_6S_SCALE);
            make.height.mas_offset(1 / HEIGHT_6S_SCALE);
        }];
    }
    return self;
}
#pragma mark - init
- (UIImageView *)headerImageView
{
    if (!_headerImageView) {
        _headerImageView = [[UIImageView alloc]init];
        _headerImageView.backgroundColor = [UIColor clearColor];
        _headerImageView.image = [UIImage imageNamed:@"btn_choose.1"];
    }
    return _headerImageView;
}
- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectZero];
        _titleLabel.backgroundColor = [UIColor clearColor];
        _titleLabel.textColor = getColor(blackColor);
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.font = DEF_FontSize_16;
        [_titleLabel sizeToFit];
        _titleLabel.text = @"一口价";
    }
    return _titleLabel;
}
- (UILabel *)detailLabel
{
    if (!_detailLabel) {
        _detailLabel = [[UILabel alloc] init];
        _detailLabel.textColor = getColor(textColor);
        _detailLabel.textAlignment = NSTextAlignmentLeft;
        _detailLabel.numberOfLines = 0;
        _detailLabel.font = DEF_FontSize_14;
        //[_detailLabel sizeToFit];
        _detailLabel.text = @"客户预约时无需付款，完成任务后线上收取费用";
    }
    return _detailLabel;
}
@end

